//
//  ViewController.m
//  webViewDemo
//
//  Created by mac on 16/5/6.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()<UIWebViewDelegate>
@property (nonatomic, strong) UIWebView *webView;
@end

@implementation ViewController

- (UIWebView *)webView
{
    if (!_webView) {
        
        _webView = [[UIWebView alloc]init];
        _webView.delegate = self;
    }
    return _webView;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.view addSubview:self.webView];
    self.webView.frame = self.view.bounds;
    
//    NSString * filePath = [[NSBundle mainBundle] pathForResource:@"error" ofType:@"html"];
//    NSString * htmlString = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
//    [self.webView loadHTMLString:htmlString baseURL:[NSURL URLWithString:filePath]];
//    
    
    NSString *url = @"http://app-test.kaipao.cc/v1/html/auctions/9?share=0&djtitle=5%E6%9C%889%E5%8F%B7%E8%8A%82%E6%97%A5%E7%9B%B4%E6%89%8E%E5%98%BF&djdesc=5%E6%9C%889%E5%93%88%E5%A5%BD%E5%BC%80%E5%BF%83&djpic=http%3A%2F%2Ffile-test.kaipao.cc%2FT3mRETBsbT1RXrhCrK.jpg";
    NSMutableURLRequest * request = [NSMutableURLRequest
                                     requestWithURL:[NSURL URLWithString:url]];
    
    /**
     *  dsflsfkdjlsd
     */
    [self.webView loadRequest:request];
}

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{

    return YES;
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    NSString *jsCode = [NSString stringWithFormat:@"getVersion('1.0.0');"];
    [self.webView stringByEvaluatingJavaScriptFromString:jsCode];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
